The number of times is the sum
$ \#\{x\in X | P(x) \} = \sum_{x\in X} [P(x)] where P: predicate
Counting the number of items that satisfy the condition" is a process of taking the sum of "1 if the condition is satisfied and 0 if not.
---
This page is auto-translated from /nishio/回数は和. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.